package top.stacktrace.gateway.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import top.stacktrace.gateway.config.auth.AuthException;

@RestControllerAdvice
public class CustomExceptionHandler {

    @ExceptionHandler(AuthException.class)
    public Mono<ResponseEntity<String>> convertIllegalAccessError(Exception e){
        //自定义逻辑，可返回其他值
        return Mono.just(new ResponseEntity<String>("need authorized.",HttpStatus.UNAUTHORIZED));
    }
}

